import {BASE_URL} from '@/services/api'
import {METHOD, request} from '@/utils/request'

export async function saveSysMenu(sysMenu, url) {
  let method = METHOD.POST
  if (url.indexOf('/') > 0) {
    method = METHOD.PATCH
  }
  return request(`${BASE_URL}/sysMenu/` + url, method, sysMenu)
}

export async function queryAllMenu() {
  return request(`${BASE_URL}/sysMenu/queryAllMenu`, METHOD.GET)
}

export async function queryMenuById(payload) {
  return request(`${BASE_URL}/sysMenu/queryMenuById`, METHOD.GET, payload)
}

export async function deleteSysMenu(payload) {
  return request(`${BASE_URL}/sysMenu/deleteSysMenu/${payload}`, METHOD.DELETE)
}